<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('eip_circuit_breaker_trolley')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="puid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :scroll="{ x: 5000,y:400 }"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.puid)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <eipCircuitBreakerTrolley-modal ref="modalForm" @ok="modalFormOk"></eipCircuitBreakerTrolley-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EipCircuitBreakerTrolleyModal from './modules/EipCircuitBreakerTrolleyModal'
  import {initDictOptions, filterDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: "EipCircuitBreakerTrolleyList",
    mixins:[JeecgListMixin],
    components: {
      EipCircuitBreakerTrolleyModal
    },
    data () {
      return {
        description: 'eip_circuit_breaker_trolley管理页面',
        // 表头
        columns: [
          {
            title: '采购方总部编码',
            align: "center",
            dataIndex: 'purchaserHqCode',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.purchaserHqCodeDictOptions, text)
            }
          },
          {
            title: '供应商名称',
            align: "center",
            dataIndex: 'supplierName'
          },
          {
            title: '供应商工单编号',
            align: "center",
            dataIndex: 'supplierWorkNo'
          },
          {
            title: '采集规范版本号',
            align: "center",
            dataIndex: 'standardVersion'
          },
          {
            title: '规格型号编码',
            align: "center",
            dataIndex: 'modelCode',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.kggModelCodeDictOptions, text)
            }
          },
          {
            title: '物资品类类型',
            align: "center",
            dataIndex: 'categoryType',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.kggCategoryTypeDictOptions, text)
            }
          },
          {
            title:'采集时间',
            align:"center",
            dataIndex: 'checkTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'入数采中心时间',
            align:"center",
            dataIndex: 'putCenterTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'工序',
            align:"center",
            dataIndex: 'pdCode'
          },
          {
            title:'感知过程',
            align:"center",
            dataIndex: 'processType'
          },
          {
            title:'相对地耐压额定值',
            align:"center",
            dataIndex: 'pressureValueUn'
          },
          {
            title:'相对地耐压值',
            align:"center",
            dataIndex: 'pressureValue'
          },
          {
            title:'真空断口耐压额定值',
            align:"center",
            dataIndex: 'vacuumVoltageUn'
          },
          {
            title:'真空断口耐压值',
            align:"center",
            dataIndex: 'vacuumVoltage'
          },
          {
            title:'相间耐压额定值',
            align:"center",
            dataIndex: 'phaseVoltageUn'
          },
          {
            title:'相间耐压值',
            align:"center",
            dataIndex: 'phaseVoltage'
          },
          {
            title:'耐压持续额定时间',
            align:"center",
            dataIndex: 'pressureTimeUn'
          },
          {
            title:'耐压持续时间',
            align:"center",
            dataIndex: 'pressureTime'
          },
          {
            title:'额定电流',
            align:"center",
            dataIndex: 'ratedCurrent'
          },
          {
            title:'额定回路电阻值',
            align:"center",
            dataIndex: 'loopResistanceUn'
          },
          {
            title:'A相回路电阻值',
            align:"center",
            dataIndex: 'loopResistanceA'
          },
          {
            title:'B相回路电阻值',
            align:"center",
            dataIndex: 'loopResistanceB'
          },
          {
            title:'C相回路电阻值',
            align:"center",
            dataIndex: 'loopResistanceC'
          },
          {
            title:'人力分合操作5次，可靠动作',
            align:"center",
            dataIndex: 'perReliableOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'储能电机85%和110%操作电压，储能可靠动作',
            align:"center",
            dataIndex: 'reliableStorageOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'等于或低于30% 额定合闸电压时，操作5次，可靠不动作',
            align:"center",
            dataIndex: 'nomVolReliableOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'85%~110%额定合闸电压（直流）范围，操作5次，可靠合闸',
            align:"center",
            dataIndex: 'nomACReliableSwitch',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'65%~110%额定分闸电压（直流）范围，操作5次，可靠分闸',
            align:"center",
            dataIndex: 'nomDCReliableSwitch',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'分闸电源低于额定30%，操作5次可靠不动作',
            align:"center",
            dataIndex: 'breakReliableNoOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'额定操作电压下，分合操作5次，均可靠动作',
            align:"center",
            dataIndex: 'breakNomVolReliableOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'额定操作电压“分-0.3-合分”，可靠动作',
            align:"center",
            dataIndex: 'breakVolReliableOper',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.isTrueDictOptions, text)
            }
          },
          {
            title:'分闸时间额定上限值',
            align:"center",
            dataIndex: 'breakTimeMax'
          },
          {
            title:'分闸时间额定下限值',
            align:"center",
            dataIndex: 'breakTimeMin'
          },
          {
            title:'A相分闸时间',
            align:"center",
            dataIndex: 'breakTimeA'
          },
          {
            title:'B相分闸时间',
            align:"center",
            dataIndex: 'breakTimeB'
          },
          {
            title:'C相分闸时间',
            align:"center",
            dataIndex: 'breakTimeC'
          },
          {
            title:'合闸时间额定上限值',
            align:"center",
            dataIndex: 'closeTimeMax'
          },
          {
            title:'合闸时间额定下限值',
            align:"center",
          },
          {
            title:'A相合闸时间',
            align:"center",
            dataIndex: 'closeTimeA'
          },
          {
            title:'B相合闸时间',
            align:"center",
            dataIndex: 'closeTimeB'
          },
          {
            title:'C相合闸时间',
            align:"center",
            dataIndex: 'closeTimeC'
          },
          {
            title:'合闸不同期额定值',
            align:"center",
            dataIndex: 'closeNotSameTimeUn'
          },
          {
            title:'合闸不同期',
            align:"center",
            dataIndex: 'closeNotSameTime'
          },
          {
            title:'分闸不同期额定值',
            align:"center",
            dataIndex: 'breakNotSameTimeUn'
          },
          {
            title:'分闸不同期',
            align:"center",
            dataIndex: 'breakNotSameTime'
          },
          {
            title:'合闸弹跳（真空断路器）额定值',
            align:"center",
            dataIndex: 'closeBounceTimeUn'
          },
          {
            title:'合闸弹跳（真空断路器）',
            align:"center",
            dataIndex: 'closeBounceTime'
          },
          {
            title:'分闸反弹幅值额定值',
            align:"center",
            dataIndex: 'breakOffAmplitudeUn'
          },
          {
            title:'分闸反弹幅值',
            align:"center",
            dataIndex: 'breakOffAmplitude'
          },
          {
            title:'（断路器小车）检验报告附件文件名',
            align:"center",
            dataIndex: 'fileName'
          },
          {
            title:'（断路器小车）检验报告附件附件对象',
            align:"center",
            dataIndex: 'fileObj'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed: 'right',
            width:150,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/eipCircuitBreakerTrolley/list",
          delete: "/eipCircuitBreakerTrolley/delete",
          deleteBatch: "/eipCircuitBreakerTrolley/deleteBatch",
          exportXlsUrl: "/eipCircuitBreakerTrolley/exportXls",
          importExcelUrl: "/eipCircuitBreakerTrolley/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['excelURL']}/${this.url.importExcelUrl}`;
        // return `http://10.89.33.69:8088/jeecg-boot/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
        initDictOptions('purchaserHqCode').then((res) => {
          if (res.success) {
            this.purchaserHqCodeDictOptions = res.result
          }
        });
        initDictOptions('kggModelCode').then((res) => {
          if (res.success) {
            this.kggModelCodeDictOptions = res.result
          }
        });
        initDictOptions('kggCategoryType').then((res) => {
          if (res.success) {
            this.kggCategoryTypeDictOptions = res.result
          }
        });
        initDictOptions('isTrue').then((res) => {
          if (res.success) {
            this.isTrueDictOptions = res.result
          }
        });
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>